<template>
  <div id="popup" class="ol-popup" v-show="isVideo">
    <span>编号:{{ number }}</span>
    <a href="#" id="popup-closer" class="ol-popup-closer"></a>
    <div id="popup-content">
      <h5>位置:{{ localtion }}</h5>
      <video width="220" height="120" controls>
        <source src="@/../monitor.mp4" type="video/mp4" />
      </video>
    </div>
  </div>
</template>

<script setup>
import { ref, onUnmounted } from 'vue'
import mitt from '@/mitt'
import Monitor from '../Hooks/Monitor'
const { openMonitor, closeMonitor } = Monitor()
const { map } = defineProps({
  map: {
    type: Object,
  },
})

const number = ref('编号:XXT06')
const localtion = ref('民族大道与雄楚大道交叉路口')
const isVideo = ref(false)
const openMonitors = () => {
  isVideo.value = true
  openMonitor(map, number, localtion)
}
const closeMonitors = () => {
  isVideo.value = false
  closeMonitor(map)
}
mitt.on('openMonitor', openMonitors)
mitt.on('closeMonitor', closeMonitors)
onUnmounted(() => {
  mitt.off('openMonitor', openMonitors)
  mitt.off('closeMonitor', closeMonitors)
})
</script>

<style scoped>
.ol-popup {
  position: absolute;
  -webkit-filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.2));
  width: 250px;
  height: 200px;
  background-color: white;
  padding: 15px;
  border-radius: 10px;
  border: 1px solid #cccccc;
  bottom: 45px;
  left: -50px;
}

.ol-popup:after,
.ol-popup:before {
  top: 100%;
  border: solid transparent;
  content: ' ';
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
}

.ol-popup:after {
  border-top-color: white;
  border-width: 10px;
  left: 48px;
  margin-left: -10px;
}

.ol-popup:before {
  border-top-color: #cccccc;
  border-width: 11px;
  left: 48px;
  margin-left: -11px;
}

.ol-popup-closer {
  text-decoration: none;
  position: absolute;
  top: 2px;
  right: 8px;
}

.ol-popup-closer:after {
  content: '×';
}
.ol-popup span {
  font-weight: 800;
}
#popup-content {
  font-size: 14px;
  font-family: '微软雅黑';
}

#popup-content img {
  width: 30px;
}
</style>
